package com.itzsj.controller;

import com.itzsj.pojo.dto.GMessageDTO;
import com.itzsj.pojo.entity.Graduate;
import com.itzsj.common.result.Result;
import com.itzsj.pojo.dto.GJobsDTO;
import com.itzsj.pojo.dto.GResumesDTO;
import com.itzsj.pojo.dto.GSendDTO;
import com.itzsj.pojo.entity.Message;
import com.itzsj.pojo.vo.GJobsVO;
import com.itzsj.pojo.vo.GResumesVO;
import com.itzsj.service.GraduateService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import java.util.List;

@RestController
@Slf4j
@RequestMapping("/graduate")
public class GraduateController {

    @Resource
    private GraduateService graduateService;

    @GetMapping("/job")
    public Result selectJob(GJobsDTO selectJobDTO) {
        log.info("selectJobDTO {}", selectJobDTO);
        List<GJobsVO> jobs = graduateService.selectJob(selectJobDTO);
        log.info("jobs {}", jobs);
        return Result.success(jobs);
    }

    @GetMapping("/get")
    public Result getResume(String sno) {
        log.info("sno {}", sno);
        Graduate graduate = graduateService.getResume(sno);
        return Result.success(graduate);
    }

    @GetMapping("/putted")
    public Result selectResume(GResumesDTO puttedResumeDTO) {
        log.info("puttedResumeDTO {}", puttedResumeDTO);
        List<GResumesVO> resumes = graduateService.selectResume(puttedResumeDTO);
        return Result.success(resumes);
    }


    @PostMapping("/put")
    public Result putResume(@RequestBody GSendDTO putResumeDTO) {
        log.info("putResumeDTO:{}", putResumeDTO);
        graduateService.putResume(putResumeDTO);
        return Result.success();
    }

    @PutMapping("/update")
    public Result updateResume(String sno, String resume) {
        log.info("sno resume {}, {}", sno, resume);
        graduateService.updateResume(sno, resume);
        return Result.success();
    }

    @PostMapping("/message")
    public Result messages(@RequestBody GMessageDTO message) {
        graduateService.messages(message);
        return Result.success();
    }

    @GetMapping("listMsg")
    public Result listMessages(String sno, String eno, Integer jobId) {
        log.info("sno eno jobId {}, {}, {}", sno, eno, jobId);
        List<Message> list = graduateService.listMessages(sno, eno, jobId);
        return Result.success(list);
    }


}
